package io;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * Created with IntelliJ IDEA.
 * Description: Writer
 * User: Li_yizYa
 * Date: 2025/5/8
 * Time: 17:36
 */
public class Demo15 {

    /**
     * 一次写入多个字符
     * @param args
     */
    public static void main(String[] args) {
        try (Writer writer = new FileWriter("./test.txt", true)) {
            char[] buffer = {'你', '好', '呀'};
            writer.write(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 一次写入一个字符
     * @param args
     */
    public static void main2(String[] args) {
        try (Writer writer = new FileWriter("./test.txt", true)) {
            writer.write("你");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 一次写入一个字符串
     * @param args
     */
    public static void main1(String[] args) {
        try (Writer writer = new FileWriter("./test.txt", true)) {
            writer.write("你好世界");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
